<template>

    <el-container >

        <el-aside >
            <el-menu >
                <span>试卷概览</span>
                <div :data="paperExerciseList" v-loading="loading2">
                    <ol>
                        <li  v-if="item.exerciseInfo.type=='1'" v-for="item in  paperExerciseList">
                            <span>单选题：</span> {{ item.choice.content}}
                            <div> <span>A</span> {{item.choice.labela}}</div>
                            <div> <span>B</span> {{item.choice.labelb}}</div>
                            <div> <span>C</span> {{item.choice.labelc}}</div>
                            <div> <span>D</span> {{item.choice.labeld}}</div>
                            <div style="margin-top: 10px ;font-weight: bold" > <span>正确答案</span> {{item.choice.answer}}</div>
                            <div style="margin-top: 10px"><span>答案解析：</span>{{item.choice.comment}}</div>
                            <div style="float: right;">
                                <el-button size="mini" icon="el-icon-delete" @click="deleteToPaper(item.exerciseInfo.id)">删除</el-button>
                            </div>
                            <hr style="margin-top: 40px">

                        </li>
                        <li  v-if="item.exerciseInfo.type=='2'" v-for="item in  paperExerciseList">
                            <span>多选题:</span>{{ item.choice.content}}
                            <div> <span>A</span> {{item.choice.labela}}</div>
                            <div> <span>B</span> {{item.choice.labelb}}</div>
                            <div> <span>C</span> {{item.choice.labelc}}</div>
                            <div> <span>D</span> {{item.choice.labeld}}</div>
                            <div v-if="item.choice.labele ==null"> <span>E</span> {{item.choice.labele}}</div>
                            <div v-if="item.choice.labelf ==null"> <span>F</span> {{item.choice.labelf}}</div>
                            <div style="margin-top: 10px;font-weight: bold"> <span>正确答案：</span> {{item.choice.answer}}</div>
                            <div style="margin-top: 10px"><span>答案解析：</span>{{item.choice.comment}}</div>
                            <div style="float: right;">
                                <el-button size="mini" icon="el-icon-delete"  @click="deleteToPaper(item.exerciseInfo.id)">删除</el-button>
                            </div>
                            <hr style="margin-top: 40px">
                        </li>
                        <li  v-if="item.exerciseInfo.type=='3'" v-for="item in  paperExerciseList">
                            <span>判断题：</span>{{ item.trueFalse.content}}
                            <div style="margin-top: 10px;font-weight: bold" v-if="item.trueFalse.answer==1"> <span>正确答案：</span> 正确</div>
                            <div style="margin-top: 10px;font-weight: bold" v-if="item.trueFalse.answer==2"> <span>正确答案：</span> 错误</div>
                            <div style="margin-top: 10px"><span>答案解析：</span>{{item.trueFalse.comment}}</div>
                            <div style="float: right;">
                                <el-button size="mini" icon="el-icon-delete" @click="deleteToPaper(item.exerciseInfo.id)">删除</el-button>
                            </div>
                            <hr style="margin-top: 40px">
                        </li>
                        <li  v-if="item.exerciseInfo.type=='4'" v-for="item in  paperExerciseList">
                            <span>填空题：</span>{{ item.completion.content}}
                            <div style="margin-top: 10px;font-weight: bold" > <span>正确答案：</span> {{item.completion.answerArray}}</div>
                            <div style="margin-top: 10px" ><span>答案解析：</span>{{item.completion.comment}}</div>
                            <div style="float: right;">
                                <el-button size="mini" icon="el-icon-delete" @click="deleteToPaper(item.exerciseInfo.id)">删除</el-button>
                            </div>
                            <hr style="margin-top: 40px">
                        </li>
                        <li  v-if="item.exerciseInfo.type=='5'" v-for="item in  paperExerciseList">
                            <span>简答题：</span>{{ item.shortAnswer.content}}
                            <div style="margin-top: 10px;font-weight: bold" > <span>正确答案：</span> {{item.shortAnswer.answer}}</div>
                            <div style="margin-top: 10px" ><span>答案解析：</span>{{item.shortAnswer.comment}}</div>
                            <div style="float: right;">
                                <el-button size="mini" icon="el-icon-delete" @click="deleteToPaper(item.exerciseInfo.id)">删除</el-button>
                            </div>
                            <hr style="margin-top: 40px">
                        </li>
                        <li  v-if="item.exerciseInfo.type=='6'" v-for="item in  paperExerciseList">
                            <span>程序设计题：</span>{{ item.programming.content}}
                            <div style="margin-top: 10px;font-weight: bold"  > <span>正确答案：</span> {{item.programming.answer}}</div>
                            <div style="margin-top: 10px"  ><span>答案解析：</span>{{item.programming.comment}}</div>
                            <div style="float: right;">
                                <el-button size="mini" icon="el-icon-delete" @click="deleteToPaper(item.exerciseInfo.id)">删除</el-button>
                            </div>
                            <hr style="margin-top: 40px">
                        </li>
                    </ol>
                    <el-button type="primary" icon="el-icon-view" style="margin-left: 120px;margin-top: 10px" @click="preview()">预览试卷</el-button>
                </div>
            </el-menu>
        </el-aside>
        <el-container>
            <el-header>
                <el-button @click="reload" icon="el-icon-arrow-left" circle ></el-button>
                <span  style="font-size:35px">组卷</span>
               <br>
                <span style="font-size:17px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;试卷名:
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{coursename}}&nbsp;&nbsp;&nbsp;
                    &nbsp;&nbsp;&nbsp;
                    <el-button type="primary" plain size="mini" @click="editexamname()">修改</el-button>
                </span>
                <span style="font-size:17px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;试卷难度:
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{delevel}}&nbsp;&nbsp;&nbsp;
                    &nbsp;&nbsp;&nbsp;
                    <el-button  plain size="mini" @click="editexamdlevel()">修改</el-button>
                </span>

            <el-header>

                <div >
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题型&nbsp;&nbsp;
                    <el-radio-group v-model="SelectData.type">
                        <el-radio :label="1">单选题</el-radio>
                        <el-radio :label="2">多选题</el-radio>
                        <el-radio :label="3">判断题</el-radio>
                        <el-radio :label="4">填空题</el-radio>
                        <el-radio :label="5">简答题</el-radio>
                        <el-radio :label="6">程序设计题</el-radio>
                    </el-radio-group>
                </div>
                <div>
                 题目难度&nbsp;&nbsp;
                    <el-radio-group  v-model="SelectData.level">
                        <el-radio :label="1">简单题</el-radio>
                        <el-radio :label="2">中等题</el-radio>
                        <el-radio :label="3">困难题</el-radio>
                    </el-radio-group>
                </div>
                <div>
                <div class="block" >
                </div>
                    <div class="block" style="margin-top: 10px">
                <span class="demonstration">知识点：
              <el-cascader
                      :options="options"
                      :show-all-levels="false"
                      :props="defaultProps"
                      v-model="SelectData.kpointId"
                      @change="getpointtree()"
              ></el-cascader>
                </span>
                    </div>
                    <div  style="margin-top: -52px;margin-left: 350px;">
                        <el-button type="primary" icon="el-icon-plus"  @click="addExercise">新增题目</el-button>
                        <el-button type="primary" icon="el-icon-sold-out" style="margin-left: 20px" @click="SearchEx">筛选题目</el-button>
                        <el-button type="primary" icon="el-icon-refresh" style="margin-left: 20px" @click="SearchClear">重置</el-button>
                    </div>
                    <hr>
                </div>
            </el-header>
            </el-header>
            <p></p> <p></p><p></p><p></p><p></p>
            <el-main  style="margin-top: 150px">
                <!--//题目渲染-->
                <div :data="exerciseList" >
                    <ol>
                        <li  v-if="item.exerciseInfo.type=='1'" v-for="item in  exerciseList">
                            <span>单选题：</span> {{ item.choice.content}}
                            <div> <span>A</span> {{item.choice.labela}}</div>
                            <div> <span>B</span> {{item.choice.labelb}}</div>
                            <div> <span>C</span> {{item.choice.labelc}}</div>
                            <div> <span>D</span> {{item.choice.labeld}}</div>
                            <div style="margin-top: 10px ;font-weight: bold" > <span>正确答案</span> {{item.choice.answer}}</div>
                            <div style="margin-top: 10px"><span>答案解析：</span>{{item.choice.comment}}</div>
                            <div style="float: right;">
                                <el-button size="mini" icon="el-icon-circle-check" @click="addToPaper(item.exerciseInfo.id)">加入试卷</el-button>
                            </div>
                            <hr style="margin-top: 40px">

                        </li>
                        <li  v-if="item.exerciseInfo.type=='2'" v-for="item in  exerciseList">
                            <span>多选题:</span>{{ item.choice.content}}
                            <div> <span>A</span> {{item.choice.labela}}</div>
                            <div> <span>B</span> {{item.choice.labelb}}</div>
                            <div> <span>C</span> {{item.choice.labelc}}</div>
                            <div> <span>D</span> {{item.choice.labeld}}</div>
                            <div v-if="item.choice.labele ==null"> <span>E</span> {{item.choice.labele}}</div>
                            <div v-if="item.choice.labelf ==null"> <span>F</span> {{item.choice.labelf}}</div>
                            <div style="margin-top: 10px;font-weight: bold"> <span>正确答案：</span> {{item.choice.answer}}</div>
                            <div style="margin-top: 10px"><span>答案解析：</span>{{item.choice.comment}}</div>
                            <div style="float: right;">
                                <el-button size="mini" icon="el-icon-circle-check"  @click="addToPaper(item.exerciseInfo.id)">加入试卷</el-button>
                            </div>
                            <hr style="margin-top: 40px">
                        </li>
                        <li  v-if="item.exerciseInfo.type=='3'" v-for="item in  exerciseList">
                            <span>判断题：</span>{{ item.trueFalse.content}}
                            <div style="margin-top: 10px;font-weight: bold" v-if="item.trueFalse.answer==1"> <span>正确答案：</span> 正确</div>
                            <div style="margin-top: 10px;font-weight: bold" v-if="item.trueFalse.answer==2"> <span>正确答案：</span> 错误</div>
                            <div style="margin-top: 10px"><span>答案解析：</span>{{item.trueFalse.comment}}</div>
                            <div style="float: right;">
                                <el-button size="mini" icon="el-icon-circle-check" @click="addToPaper(item.exerciseInfo.id)">加入试卷</el-button>
                            </div>
                            <hr style="margin-top: 40px">
                        </li>
                        <li  v-if="item.exerciseInfo.type=='4'" v-for="item in  exerciseList">
                            <span>填空题：</span>{{ item.completion.content}}
                            <div style="margin-top: 10px;font-weight: bold" > <span>正确答案：</span> {{item.completion.answerArray}}</div>
                            <div style="margin-top: 10px" ><span>答案解析：</span>{{item.completion.comment}}</div>
                            <div style="float: right;">
                                <el-button size="mini" icon="el-icon-circle-check" @click="addToPaper(item.exerciseInfo.id)">加入试卷</el-button>
                            </div>
                            <hr style="margin-top: 40px">
                        </li>
                        <li  v-if="item.exerciseInfo.type=='5'" v-for="item in  exerciseList">
                            <span>简答题：</span>{{ item.shortAnswer.content}}
                            <div style="margin-top: 10px;font-weight: bold" > <span>正确答案：</span> {{item.shortAnswer.answer}}</div>
                            <div style="margin-top: 10px" ><span>答案解析：</span>{{item.shortAnswer.comment}}</div>
                            <div style="float: right;">
                                <el-button size="mini" icon="el-icon-circle-check" @click="addToPaper(item.exerciseInfo.id)">加入试卷</el-button>
                            </div>
                            <hr style="margin-top: 40px">
                        </li>
                        <li  v-if="item.exerciseInfo.type=='6'" v-for="item in  exerciseList">
                            <span>程序设计题：</span>{{ item.programming.content}}
                            <div style="margin-top: 10px;font-weight: bold"  > <span>正确答案：</span> {{item.programming.answer}}</div>
                            <div style="margin-top: 10px"  ><span>答案解析：</span>{{item.programming.comment}}</div>
                            <div style="float: right;">
                                <el-button size="mini" icon="el-icon-circle-check" @click="addToPaper(item.exerciseInfo.id)">加入试卷</el-button>
                            </div>
                            <hr style="margin-top: 40px">
                        </li>
                    </ol>
                </div>
                <!--预览试卷-->
                <el-dialog :title="formTitle" :visible.sync="Visiblepreview" :close-on-click-modal="false">
                    <el-form  label-position="left" label-width="80px">
                        <p class="coursename">{{CurrentDate+coursename}}</p>
                        <div :data="paperExerciseList">
                            <ul style="list-style: none;padding: 0;margin: 0">
                                <span v-show="isshow1" >一、单选题：</span>
                                <li>
                                    <ol>
                                        <li v-if="item.exerciseInfo.type=='1'" v-for="item in  paperExerciseList ">
                                            <span></span> {{ item.choice.content}}
                                            <div> <span>A</span> {{item.choice.labela}}</div>
                                            <div> <span>B</span> {{item.choice.labelb}}</div>
                                            <div> <span>C</span> {{item.choice.labelc}}</div>
                                            <div> <span>D</span> {{item.choice.labeld}}</div>
                                        </li>
                                    </ol>
                                </li>
                                <span v-show="isshow2">二、多选题：</span>
                                <li>
                                    <ol>
                                        <li v-if="item.exerciseInfo.type=='2'" v-for="item in  paperExerciseList ">
                                            <span></span> {{ item.choice.content}}
                                            <div> <span>A</span> {{item.choice.labela}}</div>
                                            <div> <span>B</span> {{item.choice.labelb}}</div>
                                            <div> <span>C</span> {{item.choice.labelc}}</div>
                                            <div> <span>D</span> {{item.choice.labeld}}</div>
                                            <div v-if="item.choice.labele ==null"> <span>E</span> {{item.choice.labele}}</div>
                                            <div v-if="item.choice.labelf ==null"> <span>F</span> {{item.choice.labelf}}</div>
                                        </li>
                                    </ol>
                                </li>
                                <span v-show="isshow3">三、判断题：</span>
                                <li>
                                    <ol>
                                        <li v-if="item.exerciseInfo.type=='3'" v-for="item in  paperExerciseList ">
                                            <span></span> {{ item.trueFalse.content}}
                                        </li>
                                    </ol>
                                </li>
                                <span v-show="isshow4">四、填空题：</span>
                                <li>
                                    <ol>
                                        <li v-if="item.exerciseInfo.type=='4'" v-for="item in  paperExerciseList ">
                                            <span></span>{{ item.completion.content}}
                                        </li>
                                    </ol>
                                </li>
                                <span v-show="isshow5">五、简答题：</span>
                                <li>
                                    <ol>
                                        <li v-if="item.exerciseInfo.type=='5'" v-for="item in  paperExerciseList ">
                                            <span></span>{{ item.shortAnswer.content}}
                                        </li>
                                    </ol>
                                </li>
                                <span v-show="isshow6">六、程序设计题：</span>
                                <li>
                                    <ol>
                                        <li v-if="item.exerciseInfo.type=='6'" v-for="item in  paperExerciseList ">
                                            <span></span>{{ item.programming.content}}
                                        </li>
                                    </ol>
                                </li>
                            </ul>
                        </div>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click.native="Visiblepreview = false" type="primary" >生成试卷</el-button>
                        <el-button @click.native="Visiblepreview = false">关闭</el-button>
                    </div>
                </el-dialog>
                <!--新增题目-->
                <el-dialog :title="formTitle" :visible.sync="addformVisible" :close-on-click-modal="false">
                    <el-form :model="formData" label-width="80px" :rules="formRules" ref="formData">
                        <div>
                            <el-radio-group v-model="formData.exerciseInfo.type">
                                <el-radio :label="1">单选题</el-radio>
                                <el-radio :label="2">多选题</el-radio>
                                <el-radio :label="3">判断题</el-radio>
                                <el-radio :label="4">填空题</el-radio>
                                <el-radio :label="5">简答题</el-radio>
                                <el-radio :label="6">程序设计题</el-radio>
                            </el-radio-group>
                        </div>
                        <div style="margin-top: 30px">
                            <el-radio-group v-model="formData.exerciseInfo.dlevel">
                                <el-radio :label="1">简单题</el-radio>
                                <el-radio :label="2">中等题</el-radio>
                                <el-radio :label="3">困难题</el-radio>
                            </el-radio-group>
                        </div>
                    </el-form>
                    <div v-if="formData.exerciseInfo.type == '1'" >
                        <el-form :model="formData" label-width="80px" :rules="formRules" ref="formData">
                            <div style="margin-top: 30px">
                                题干
                                <!--<el-input-->
                                <!--type="textarea"-->
                                <!--:rows="5"-->
                                <!--placeholder="请输入题干"-->
                                <!--v-model="formData.choice.content">-->
                                <!--</el-input>-->
                            </br>
                                <textarea id="editor" rows="10" cols="80"></textarea>
                            </div>
                            <div style="margin-top: 30px">
                                A选项内容
                                <el-input v-model="formData.choice.labelA" placeholder="请输入A标识"></el-input>
                                B选项内容
                                <el-input v-model="formData.choice.labelB" placeholder="请输入B标识"></el-input>
                                C选项内容
                                <el-input v-model="formData.choice.labelC" placeholder="请输入C标识"></el-input>
                                D选项内容
                                <el-input v-model="formData.choice.labelD" placeholder="请输入D标识"></el-input>
                            </div>
                            <div style="margin-top: 30px">
                                正确答案
                                <el-radio-group v-model="formData.choice.answer">
                                    <el-radio label="A">A</el-radio>
                                    <el-radio label="B">B</el-radio>
                                    <el-radio label="C">C</el-radio>
                                    <el-radio label="D">D</el-radio>
                                </el-radio-group>
                            </div>

                            <div style="margin-top: 30px">
                                答案说明
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="请输入答案说明"
                                        v-model="formData.choice.comment">
                                </el-input>
                            </div>
                        </el-form>
                    </div>
                    <div v-else-if="formData.exerciseInfo.type == '2'">
                        <el-form :model="formData" label-width="80px" :rules="formRules" ref="formData">
                            <div style="margin-top: 30px">
                                题干
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="请输入题干"
                                        v-model="formData.choice.content">
                                </el-input>
                            </div>
                            <div style="margin-top: 30px">
                                A选项内容
                                <el-input v-model="formData.choice.labelA" placeholder="请输入A标识"></el-input>
                                B选项内容
                                <el-input v-model="formData.choice.labelB" placeholder="请输入B标识"></el-input>
                                C选项内容
                                <el-input v-model="formData.choice.labelC" placeholder="请输入C标识"></el-input>
                                D选项内容
                                <el-input v-model="formData.choice.labelD" placeholder="请输入D标识"></el-input>
                                E选项内容
                                <el-input v-model="formData.choice.labelE" placeholder="请输入E标识"></el-input>
                                F选项内容
                                <el-input v-model="formData.choice.labelF" placeholder="请输入F标识"></el-input>
                            </div>
                            <div style="margin-top: 30px">
                                正确答案
                                <el-checkbox-group v-model="formData.choice.answer">
                                    <el-checkbox label="A"></el-checkbox>
                                    <el-checkbox label="B"></el-checkbox>
                                    <el-checkbox label="C"></el-checkbox>
                                    <el-checkbox label="D"></el-checkbox>
                                    <el-checkbox label="E"></el-checkbox>
                                    <el-checkbox label="F"></el-checkbox>
                                </el-checkbox-group>

                            </div>

                            <div style="margin-top: 30px">
                                答案说明
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="请输入答案说明"
                                        v-model="formData.choice.comment">
                                </el-input>
                            </div>
                        </el-form>
                    </div>
                    <div v-else-if="formData.exerciseInfo.type == '3'">
                        <el-form :model="formData" label-width="80px" :rules="formRules" ref="formData">
                            <div style="margin-top: 30px">
                                题干
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="请输入题干"
                                        v-model="formData.trueFalse.content">
                                </el-input>
                            </div>
                            <div style="margin-top: 30px">
                                正确答案
                                <el-radio-group v-model="formData.trueFalse.answer">
                                    <el-radio :label="-1">错</el-radio>
                                    <el-radio :label="1">对</el-radio>
                                </el-radio-group>
                            </div>
                            <div style="margin-top: 30px">
                                答案说明
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="答案说明"
                                        v-model="formData.trueFalse.comment">
                                </el-input>
                            </div>
                        </el-form>
                    </div>
                    <div v-else-if="formData.exerciseInfo.type == '4'">
                        <el-form :model="formData" label-width="80px" :rules="formRules" ref="formData">
                            <div style="margin-top: 30px">
                                题干
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="请输入题干"
                                        v-model="formData.completion.content">
                                </el-input>
                            </div>
                            <div style="margin-top: 30px">
                                第一空
                                <el-input v-model="formData.completion.answerArray[0]" placeholder="第一空"></el-input>
                                第二空
                                <el-input v-model="formData.completion.answerArray[1]" placeholder="第二空"></el-input>
                                第三空
                                <el-input v-model="formData.completion.answerArray[2]" placeholder="第三空"></el-input>
                                第四空
                                <el-input v-model="formData.completion.answerArray[3]" placeholder="第四空"></el-input>
                            </div>
                            <div style="margin-top: 30px">
                                答案说明
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="请输入答案说明"
                                        v-model="formData.completion.comment">
                                </el-input>
                            </div>
                        </el-form>
                    </div>
                    <div v-else-if="formData.exerciseInfo.type == '5'">
                        <el-form :model="formData" label-width="80px" :rules="formRules" ref="formData">
                            <div style="margin-top: 30px">
                                题干
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="请输入题干"
                                        v-model="formData.shortAnswer.content">
                                </el-input>
                            </div>
                            <div style="margin-top: 30px">
                                答案
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="请输入答案"
                                        v-model="formData.shortAnswer.answer">
                                </el-input>
                            </div>
                            <div style="margin-top: 30px">
                                答案说明
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="答案说明"
                                        v-model="formData.shortAnswer.comment">
                                </el-input>
                            </div>
                        </el-form>
                    </div>
                    <div v-else-if="formData.exerciseInfo.type == '6'">
                        <el-form :model="formData" label-width="80px" :rules="formRules" ref="formData">
                            <div style="margin-top: 30px">
                                题干
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="请输入题干"
                                        v-model="formData.programming.content">
                                </el-input>
                            </div>
                            <div style="margin-top: 30px">
                                答案
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="请输入答案"
                                        v-model="formData.programming.answer">
                                </el-input>
                            </div>
                            <div style="margin-top: 30px">
                                答案说明
                                <el-input
                                        type="textarea"
                                        :rows="5"
                                        placeholder="答案说明"
                                        v-model="formData.programming.comment">
                                </el-input>
                            </div>
                        </el-form>
                    </div>
                    <div v-else style="margin-top: 30px">
                        **********************************请先选择题型**************************************
                    </div>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click.native="addformVisible = false">取消</el-button>
                        <el-button type="primary" @click.native="" :loading="submitLoading">提交</el-button>
                    </div>
                </el-dialog>

                <!--改变分值-->
                <el-dialog :title="formTitle" :visible.sync="claimVisible" :close-on-click-modal="false">
                    <el-form  label-position="left" label-width="80px">
                        <el-form-item label="分值">
                            <el-input  v-model="Source" placeholder="请输入分值"></el-input>
                        </el-form-item>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click.native="claimVisible = false">取消</el-button>
                        <el-button type="primary"  @click="submitExercise" :loading="submitLoading">提交</el-button>
                    </div>
                </el-dialog>

               <!-- 编辑考试名称属性-->
                <el-dialog :title="formTitle" :visible.sync="enVisible" :close-on-click-modal="false">
                    <el-form label-width="80px" label-position="right">
                        <el-form-item label="试卷名">
                            <el-input style="width:265px" v-model="coursename"></el-input>
                            <p></p>
                        </el-form-item>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click.native="enVisible = false">取消</el-button>
                        <el-button type="primary" v-on:click="subexamname" :loading="submitLoading">提交</el-button>
                    </div>
                </el-dialog>



                <!--编辑考试难度属性-->
                <el-dialog :title="formTitle" :visible.sync="edVisible" :close-on-click-modal="false">
                    <el-form label-width="80px" label-position="right">
                    <el-form-item label="试卷难度"  size="mini"  >
                        <el-radio-group  v-model="delevel">
                            <el-radio label="简单" border>简单</el-radio>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <el-radio label="中等" border>中等</el-radio>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <el-radio label="困难" border>困难</el-radio>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        </el-radio-group>
                    </el-form-item>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click.native="edVisible = false">取消</el-button>
                        <el-button type="primary" v-on:click="subexamdl" :loading="submitLoading">提交</el-button>
                    </div>

                </el-dialog>

            </el-main>
        </el-container>
    </el-container>
</template>


<style>

    .el-header {
        color: #333;
        line-height: 50px;

    }
    .el-aside {
        color: #333;
    }
</style>

<script>

    export default {
        data(){
            return {
                loading2:true,
                delevel:'',
                coursename:'',
                dlevel:'',
                date: Date.parse(new Date()),
                CurrentDate:'',
               // formVisible:'',
                teacherid:'',
                laoshiid:'',
                formVisible:false,
                Visiblepreview:false,
                addformVisible:false,
                enVisible:false,
                edVisible:false,
                isshow1:false,
                isshow2:false,
                isshow3:false,
                isshow4:false,
                isshow5:false,
                isshow6:false,

                //新增页面数据
                formData: {
                    exerciseInfo:{
                        type: '',
                        dlevel: '',
                        courseid: this.$route.query.courseid,
                    },
                    choice: {
                        content: '',
                        answer: [],
                        comment: '',
                        labelA: '',
                        labelB: '',
                        labelC: '',
                        labelD: '',
                        labelE: '',
                        labelF: '',
                    },//选择题
                    trueFalse: {
                        content: '',
                        answer: '',
                        comment: '',
                    }, //判断题
                    shortAnswer: {
                        content: '',
                        answer: '',
                        comment: '',
                    },//简答题
                    completion: {
                        answerArray:[],
                        comment:'',
                        content:'',
                    },//填空题
                    programming: {
                        content: '',
                        answer: '',
                        comment: '',
                    },//程序设计题
                    kpointtree:{
                        exerinfoid:'',
                        kpointids:[],
                    }//知识点树
                },
                courseid:'',
                paperid:'',
                exerciseID:'',
                options:[],
                chuangzhi:'',
                KpointTree:[],
                defaultProps: {
                    children: 'children',
                    label: 'label',
                    value:'id'
                },
                claimVisible:false,
                formTitle:'',
                SelectData:{
                    kpointId:[],
                    type:'',
                    level:'',
                },
                Source:'',
                submitLoading: false,
                exerciseList:{},
                total: 0,

                pageIndex: 1, //页码
                pageSize: this.CONSTANT.PAGE_SIZE, //分页大小
                pageSizes: this.CONSTANT.PAGE_SIZES, //分页大小选择列表
                formRules: {
                    username: [
                        {required: true, message: '请输入用户名', trigger: 'blur'}
                    ],
                    mobilephone: [{
                        validator: (rule, value, callback) => {

                            let reg = /^1[3|4|5|8][0-9]\d{4,8}$/;

                            if (reg.test(value) == false && value) {
                                callback(new Error("手机号格式不正确"));
                            }
                        }, trigger: 'blur'
                    }],
                    usertype: [{required: true, message: "请选择用户类别", trigger: 'blur'}]
                },
                paperExerciseList:[],
            }
        },

        methods:{
            reload(){
                this.$router.push({path:"/exampaper",query:{courseid:this.chuangzhi}});
            },
            getDataList(){
                //获取知识点树渲染搜索框
                console.log(this.chuangzhi);
                this.$http.get("/api/kpoint/getKpointTree/"+this.chuangzhi).then((res)=>{
                    console.log(res);
                    console.log("zheliaaaaa");
                    this.options=res.data.data;
                }).catch((error)=>{
                    console.log(error);
                });
                //试卷概览
                this.$http.post("/api/composePaper/findByPaperid/"+this.paperid).then((res)=>{
                    console.log(res.data);
                    this.paperExerciseList=res.data.data;
                    for(let i=0;i<this.paperExerciseList.length;i++){
                        if(this.paperExerciseList[i].exerciseInfo.type===1){
                            this.isshow1=true;
                        }
                        else if(this.paperExerciseList[i].exerciseInfo.type===2){
                            this.isshow2=true;
                        }
                        else if(this.paperExerciseList[i].exerciseInfo.type===3){
                            this.isshow3=true;
                        }
                        else if(this.paperExerciseList[i].exerciseInfo.type===4){
                            this.isshow4=true;
                        }
                        else if(this.paperExerciseList[i].exerciseInfo.type===5){
                            this.isshow5=true;
                        }
                        else if(this.paperExerciseList[i].exerciseInfo.type===6){
                            this.isshow6=true;
                        }
                    }
                    this.loading2=false;
                }).catch((error)=>{
                    console.log(error);
                });
                console.log(this.delevel+"    22222");
                //试卷难度修改载入
                this.$http.post('/api/exampaper/findByid/'+this.paperid).then(res=>{
                    this.coursename=res.data.data.name;
                    this.dlevel=res.data.data.dlevel;
                    this.laoshiid=res.data.data.teacherid;
                    console.log(this.dlevel+"登");
                    if(this.dlevel==2){
                        this.delevel = "中等";
                    }
                    if(this.dlevel==1){
                        this.delevel = "简单";
                    }
                    if(this.dlevel==3){
                        this.delevel = "困难";
                    }
                    console.log(this.delevel+'123');
                }).catch((error)=>{
                    console.log(error);
                });

            },
            addToPaper(num){
                this.claimVisible = true;
                this.formTitle = '输入分值';
                this.exerciseID=num;
            },
            deleteToPaper(num){
                //this.claimVisible = true;
                this.formTitle = '输入分值';
                this.exerciseID=num;
            },
            getpointtree(){

            },
            SearchClear(){
                this.SelectData={
                    kpointId:[],
                    type:'',
                    level:'',
                }
            },
            SearchEx(){
                let para = {
                    pageIndex: this.pageIndex,
                    pageSize: this.pageSize,
                    courseid:this.courseid,
                    kpoints: this.SelectData.kpointId[1],
                    type:this.SelectData.type,
                    level:this.SelectData.level,

                };
                this.$http.post('/api/exercise/findByCondition',para).then((res)=>{
                    console.log(res.data.data);
                    this.exerciseList=res.data.data;
                }).catch((error)=>{
                })

            },
            addExercise(){
                this.addformVisible=true;
                console.log(this.addformVisible);
               // this.formVisible = true;
/*
                this.formData = {
                    name: '',
                    creatorid: this.teacherid,
                };
*/
            },
            submitExercise(){
                let para ={
                    points:this.Source,
                    exerinfoid:this.exerciseID,
                    paperid:this.paperid,
                };

                this.$http.post('/api/composePaper/add',para).then((res)=>{
                    this.claimVisible = false;
                    if(!res.data.code){
                        this.$message({
                            message: res.data.msg,
                            type: 'success',
                        });

                    }else{
                        this.$message({
                            message: res.data.msg,
                            type: 'error'
                        })
                    }
                    this.Source='';
                    this.getDataList();
                }).catch((error)=>{
                    console.log(error);
                })
            },
            getTeacherInfo() {
                this.user = JSON.parse(localStorage.getItem("CurrentUser"));//获取userid
                this.$http.get('/api/teacherinfo/findTeacherByUserid/' + this.user.id).then((res) => {
                    this.teacherid = res.data.teacherInfo.id;
                }).catch((error) => {
                });//查询teacherid
            },
            saveSubmit: function () {
                this.$confirm('确认提交吗？', '提示', {}).then(() => {
                    this.submitLoading = true;
                    let para = Object.assign({}, this.formData);
                    this.$http.post('/api/exercise/addExer', this.formData).then(res => {
                        this.submitLoading = false;
                        if (res.data.code == 0) {
                            this.$message({
                                message: '提交成功',
                                type: 'success'
                            });
                            this.$refs['formData'].resetFields();
                            this.formVisible = false;
                            // this.getDataList(); //重新加载数据
                        } else {
                            this.$message({
                                message: '提交失败',
                                type: 'error'
                            });
                        }
                    }).catch((error) => {
                        this.submitLoading = false;
                        if (error) console.log(error);
                    });

                });
            },
            preview(){
                this.formTitle='预览试卷';
                this.Visiblepreview=true;
                var curdate = new Date(this.date);

                var Y = curdate.getFullYear();
                var M = (curdate.getMonth()+1 < 10 ? '0'+(curdate.getMonth()+1) : curdate.getMonth()+1) ;
                var D = curdate.getDate();
                this.CurrentDate=Y+'年'+M+'月'+D+'日';
            },
            editexamname(){
                this.enVisible=true;
                this.formTitle='修改考试名称';
                /*console.log(this.coursename);
                console.log(this.teacherid);
                console.log(this.paperid);*/
            },
            editexamdlevel(){
                this.edVisible=true;
                this.formTitle='修改考试难度';
            },
            subexamname(){
                let cur={
                    id:this.paperid,
                    name:this.coursename,
                    teacherid:this.laoshiid,
                };
               /* console.log(this.paperid+"papa");
                console.log(this.teacherid);
                console.log(cur);*/
                this.$http.post('/api/exampaper/change/'+this.teacherid,cur).then((res) => {
                        /*console.log(res.data.code);*/
                    if (res.data.code === 0) {
                        this.$message({
                            message: '修改成功',
                            type: 'success'
                        });
                    } else {
                        this.$message({
                            message: '修改失败',
                            type: 'error'
                        });
                    }
                    this.enVisible=false;
                    this.getDataList();
                }).catch(() => {
                    if (error) console.log(error);
                });
            },
            subexamdl(){
                if(this.delevel=='简单'){
                    this.dlevel = 1;
                }
                if(this.delevel=='中等'){
                    this.dlevel = 2;
                }
                if(this.delevel=='困难'){
                    this.dlevel = "3";
                }
                let cur={
                    id:this.paperid,
                    teacherid:this.laoshiid,
                    dlevel:this.dlevel,
                };

                this.$http.post('/api/exampaper/change/'+this.teacherid,cur).then((res) => {
                  /*  console.log(res.data.code);*/
                    if (res.data.code === 0) {
                        this.$message({
                            message: '修改成功',
                            type: 'success'
                        });
                    } else {
                        this.$message({
                            message: '修改失败',
                            type: 'error'
                        });
                    }
                    this.edVisible=false;
                    this.getDataList();
                }).catch(() => {
                    if (error) console.log(error);
                });
            }
        },
        mounted() {
            this.paperid = this.$route.query.id;
            this.courseid = this.$route.query.courseid;
            this.chuangzhi=this.$route.query.chuangzhi;
            this.getDataList();
            this.getTeacherInfo();
            /*console.log(this.chuangzhi+"跳转");*/
        }
    };
</script>
<style>
    .coursename{
        font-size:20px;
        text-align: center;
    }
</style>